<?php
/*
err
错误处理
return errorReturn('无效的参数');
------------------

find
详情
$param = request()->post();
$id = $param['id'] ?? 0;
if (!$id) {
    return errorReturn('缺少参数id');
}
$where = [['id', '=', $id]];
$exist = Db::table('table_name')->where($where)->find();
if (!$exist) {
    return errorReturn('无效的参数id');
}
return successReturn($exist);
------------------

suc
成功返回
return successReturn();

trans
事务
try {
    Db::startTrans();
    $affect_rows = Db::table('work_order')->insertAll($insert_data_all);
    Db::commit();
} catch (\Exception $e) {
    Db::rollback();
    return errorReturn($e->getMessage());
}
------------------

try
异常处理
try {
    $where = [
        ['del', '=', 0],
    ];
    $exist = Db::table('table_name')->where($where)->find();
    if (!$exist) {
        return errorReturn('无效的参数');
    }
} catch (\Exception $e) {
    return errorReturn($e->getMessage());
}

------------------

update
更新数据
$param = request()->post();
$post['id'] = $param['id'] ?? 0;
$post['field1'] = $param['field1'] ?? '';
$post['field2'] = $param['field2'] ?? '';
checkPost($post);
$where = [['id', '=', $post['id']]];
$exist = Db::table('table_name')->where($where)->find();
if (!$exist) {
    return errorReturn('无效的参数id');
}
Db::table('tablename')->where($where)->update($post);
return successReturn();

------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------
------------------

*/